package cn.hncj.lyc.controller.pay;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.hncj.lyc.bean.OrderManagement;
import cn.hncj.lyc.service.OrderStateService;

/**
 * 微信支付 controller
 */
@Controller
@RequestMapping("/weixinpay")
public class WeixinpayController {
	
	@Autowired
	OrderStateService orderStateService;
	@RequestMapping("/selectpay")
	public String selectpay( OrderManagement orderManagement,Model model) {
          try {
			
        	  orderStateService.updateOrderState(orderManagement);
			model.addAttribute("orderpayid", "成功");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			//e.printStackTrace();
			model.addAttribute("result", "修改用户信息失败");
		}
		return "pay/pay";
		
	}
	@RequestMapping("/wxpay")
	public String wxpay(OrderManagement ordermanagement,HttpSession session,Model model) {
		try {
			orderStateService.updateOrderState(ordermanagement);
			model.addAttribute("orderpayid", "成功");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			//e.printStackTrace();
			model.addAttribute("result", "修改用户信息失败");
		}
		return "pay/pay";		
	}

	
	@RequestMapping("/wxpaysuccess")
	public String wxpaysu() {
		return"pay/paysuccess";
	}
	@RequestMapping("/wxpayfail")
	public String wxpayfa() {
		return"pay/payfail";
	}
}
